{extend name='public/layout' /}
{block name='search'}{/block}
{block name='content'}

<div class="login_bg">
    <div class="loin_mid">
        <div class="tab05">
            <ul class="idTabs">
                <li><a href="{:url('user.login/index')}">登录</a></li>
                <li><a href="{:url('user.login/pass')}" class="selected">找回密码</a></li>
            </ul>
        </div>
        <form action="{:url('pass')}" method="post" name="myForm" id="myForm" data-uri="{:url('ajaxCheckUser')}">
            <div class="loin_body mar05">
                <div class="login_n1"><span class="login_ico01"></span>
                <input id="mobile" name="mobile" type="text" class="input04" placeholder="请填写注册时的手机号码">
            </div>
                <div class="login_n1"><span class="login_ico04"></span>
                    <input id="email" name="email" type="text" class="input04" placeholder="请填写注册时的邮箱号码">
                </div>
                <div class="loin_body">
                    <div class="overflow_h">
                        <div class="login_n3"><span class="login_ico03"></span>
                            <input name="code" id="code" type="text" class="input05" placeholder="请输入邮箱收到的验证码">
                        </div>
                        <div class="login_n4">
                            <a href="javascript:;" class="but25" onclick="getCode();" id="smsCode">获取验证码</a>
                        </div>
                    </div>
                </div>
                <div class="loin_body">
                    <div class="login_n1"><span class="login_ico02"></span>
                        <input id="password" name="password" type="password" class="input04" placeholder="请设置密码">
                    </div>
                </div>
                    <div class="loin_body">
                        <div class="login_n1"><span class="login_ico02"></span>
                         <input id="repassword" name="repassword" type="password" class="input04" placeholder="请填写确认密码">
                        </div>
                    </div>
                <p><a href="javascript:;" onclick="$('#myForm').submit();" class="but22">重置密码</a></p>
            </div>

        </form>


    </div>
</div>
<script src="__PUBLIC__/js/plugins/layervalide.js"></script>
<script src="__PUBLIC__/js/plugins/jquery.ajax.form.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
    $(function(){
        $.formValidator.initConfig({formid:"myForm",autotip:true});
        $("#mobile").formValidator({onshow:'',onfocus:'请填写手机号码'}).regexValidator({regexp:"mobile",datatype:"enum",onerror:"请填写注册时的手机号码"}).ajaxValidator({
            type : "get",
            url : $('#myForm').data('uri'),
            datatype : "json",
            async:'false',
            success : function(result){
                if(result.status == 1){
                    return false;
                }else{
                    return true;
                }
            },
            onerror : '该手机号码不存在',
            onwait : '查询中,请稍候...'
        });
        $("#email").formValidator({onshow:'',onfocus:'请填写邮箱号码'}).regexValidator({regexp:"email",datatype:"enum",onerror:"请填写注册时的邮箱号码"}).ajaxValidator({
            type : "get",
            url : $('#myForm').data('uri'),
            datatype : "json",
            async:'false',
            success : function(result){
                if(result.status == 1){
                    return false;
                }else{
                    return true;
                }
            },
            onerror : '该邮箱号码不存在',
            onwait : '查询中,请稍候...'
        });
        $("#code").formValidator({onshow:'',onfocus:'请填写验证码'}).inputValidator({min:6,max:6,onerror:'验证码由6个字符组成'});
        $("#password").formValidator({onshow:'',onfocus:'请填写密码'}).inputValidator({min:6,onerror:'密码至少由6个字符组成'});
        $("#repassword").formValidator({onshow:"",onfocus:"请再次填写密码"}).compareValidator({desid:"password",operateor:"=",onerror:"输入两次密码不同。"});
       $('#myForm').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            if(result.status == 1){
                layer.msg(result.msg,{icon:1});
                setTimeout(function(){window.location.href = result.uri;},2000);
            } else {
                layer.msg(result.msg,{icon:2});
            }
        }
    });
    var time=60,times='';
    function getCode(){
        if(time<60) return false;
        var email = $("#email").val(),mobile=$("#mobile").val();
        $.post("{:url('user.login/getEmailCode')}",{'email':email,'mobile':mobile},function(data){
            if(data.status==1){
                time --;
                layer.msg('验证码发送成功，请注意查收',{icon:1});
                times = setInterval(timer,1000);
            }else{
                alert(data.msg);
            }
        });
    }
    function timer(){
        var code = $("#smsCode");
        if(time == 0){
            time = 61;
            code.text('获取验证码');
            clearInterval(times);

        }else{
            code.text(time+'秒后重新获取');
        }
        time --;
    }
</script>
{/block}